﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:myCollections.Controls">

    <Style TargetType="{x:Type local:BusyIndicator}">
        <Setter Property="Background" Value="Black" />
        <Setter Property="Opacity" Value="0.5" />
        <Setter Property="BorderBrush" Value="{x:Null}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="IsHitTestVisible" Value="False" />
        <Setter Property="Panel.ZIndex" Value="5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:BusyIndicator}">
                    <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                        Visibility="Collapsed" CornerRadius="3"	BorderThickness="{TemplateBinding BorderThickness}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="Busy">
                                <VisualState x:Name="NotBusy" />
                                <VisualState x:Name="IsBusy">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0.200" Value="{x:Static Visibility.Visible}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)" Storyboard.TargetName="progressBar" To="-360" RepeatBehavior="Forever" Duration="0:0:1" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <StackPanel x:Name="content" Margin="3,2" IsHitTestVisible="False" VerticalAlignment="Center">
                            <Image Source="/myCollections;component/Images/WaitCircle.png" Stretch="None" x:Name="progressBar" RenderTransformOrigin="0.5,0.5">
                                <Image.RenderTransform>
                                    <RotateTransform  />
                                </Image.RenderTransform>
                            </Image>
                            <TextBlock HorizontalAlignment="Center" Text="{TemplateBinding BusyMessage}" Style="{DynamicResource WaitTextStyle}"/>
                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



</ResourceDictionary>